package client.skills;

import client.PurePlayer;
import java.lang.ref.WeakReference;
import packet.creators.MainPacketCreator;

public class CancelCooldownAction implements Runnable {

    private int skillId;
    private WeakReference<PurePlayer> target;

    public CancelCooldownAction(PurePlayer target, int skillId) {
	this.target = new WeakReference<PurePlayer>(target);
	this.skillId = skillId;
    }

    @Override
    public void run() {
	final PurePlayer realTarget = target.get();
	if (realTarget != null) {
	    realTarget.removeCooldown(skillId);
	    realTarget.getClient().getSession().write(MainPacketCreator.skillCooldown(skillId, 0));
	}
    }
}
